
function getIds(){
		var ids="";
		var $cks=$("input[type='checkbox'][name='ck']:checked");
		var len = $cks.length;
		if(len==0){
			return null;
		}else{
			$cks.each(function(index){
   			if(index==len-1){
   				ids+=$(this).parents("tr").attr("dataid");
   			}else{
   				ids+=$(this).parents("tr").attr("dataid")+",";
   			} 
   		});
			return ids;
		}
}

//新增
function add(type){
	$('#div_right').load("/"+type+"/add");
	
}

//编辑
function edit(type,id){
	$('#div_right').load("/"+type+"/edit?id="+id);
	
}

//删除
function del(type){
	var ids=getIds();
  		if(ids==null){
  			alert("请选择");
  		}else if(confirm("确认要删除？")){
   		$.post("/"+type+"/delete",{ids:ids},function(data){
   			if(data=='success'){
   				$('#div_right').load("/"+type+"/manage");
   			}
   		});
  		}
}
	
function checkOne(){
	var $subs = $("input[name='ck']");
	$("input[name='checkAll']").prop("checked" , $subs.length == $subs.filter(":checked").length ? true :false);
}
	
function checkAll(){
	$('input[name="ck"]').prop("checked",$("input[name='checkAll']").prop("checked"));
} 

function updateIndexPage(){
	$('#btn_update').attr("disabled","disabled");
	$.get("/index/create",function(data){
		if(data=="success"){
			alert("更新首页成功");
		}else{
			alert("更新首页失败");
		}
		$('#btn_update').removeAttr("disabled");
	});
		
}